using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using WMOSSExperts.Diagnostics;

namespace WMOSSExperts.Features
{
    [CLSCompliant(false)]
    public class WMOSSExpertsAdminBaseReceiver : BaseFeatureReceiver
    {
        public WMOSSExpertsAdminBaseReceiver()
        {
            //System.Threading.Thread.Sleep(new TimeSpan(0, 0, 20));

        }

        public override void OnFeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties properties)
        {
            base.OnFeatureActivated(properties);
            if (this.Service != null)
            {
                this.Service.Farm.Services.Add(new DiagnosticsManager());
            }
        }

        public override void OnFeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties properties)
        {
            base.OnFeatureDeactivating(properties);
            if (this.Service != null)
            {
                foreach (SPService service in this.Service.Farm.Services)
                {

                    if (service is DiagnosticsManager) service.Delete();
                }
                this.Service.Farm.Update();

            }
        }
    }
}
